home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!txwang
- From: Wang TianXing <gztxwang@public1.guangzhou.gd.cn>
- Newsgroups: comp.lang.c++
- Subject: Re: Symantec 7.2 Hello World Problem
- Date: Sun, 24 Mar 1996 10:54:14 GMT
- Message-ID: <199603232309.HAA22808@public1.guangzhou.gd.cn>
- X-NNTP-Posting-Host: txwang
- X-Newsreader: Forte Free Agent 1.0.82
- X-Mail2News-Path: public1.guangzhou.gd.cn!txwang
-
- On Fri, 22 Mar 1996 10:02:55 -0500, Ron Romero <ron.romero@ssds.com>
- wrote:
-
- | I'm having trouble doing a C++ Hello World program with Symantec C++ 7.2, using output to windows
- | 3.11 console. It seems like this should be trivial, but it dowsn't work. It works with printf,
- | but cout produces no output.
-
- | Here's the code:
-
- | -----Cut Here------------
- | #include <iostream.h>
- | #include <stdio.h>
-
- | main()
- | {
- | cout << "Hello World" << endl;
-
- | printf("Goodbye World\n");
- | }
- | -----Cut Here------------
-
- | This produces "Goodbye World" on the first line of the console window.
-
- | Any ideas? Am I just not linking right?
-
- | Ron Romero
-
- Generally, you cannot mix cout and printf(), because both of them are
- bufferring outputs.
-
- So, if you remove the printf(...), you'll see "Hello World" on the
- console. If you insist to mix cout and printf(), try this:
-
- #include <iostream.h>
- #include <stdio.h>
-
- int main()
- {
- cout << "Hello World" << endl;
- cout.flush();
- printf( "Goodbye World\n" );
- fflush( stdout );
- return 0;
- }
-
- I believe this question is in the FAQ:
-
- ftp://rtmf.mit.edu/pub/usenet-by-group/comp.lang.c++/*
-
-
- ---
- Wang TianXing
-
-
-